package com.yurun.controller.admin;

import com.yurun.entity.ExceptionLog;
import com.yurun.model.vo.Result;
import com.yurun.service.ExceptionLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/admin")
public class ExceptionLogController {
    @Autowired
    ExceptionLogService exceptionLogService;
    /**
     * @Description: 添加报错日志
     * @Param: exceptionLog
     * @return: void
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @PostMapping("/exceptionlog")
    public void addExceptionLog(@RequestBody ExceptionLog exceptionLog){
        exceptionLogService.addExceptionLog(exceptionLog);
    }
    /**
     * @Description: 删除报错日志
     * @Param: id
     * @return: void
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @DeleteMapping("/exceptionlog/id")
    public void deleteExceptionLog(@RequestParam Long id){
        exceptionLogService.deleteExceptionLogById(id);
    }
    /**
     * @Description: 通过日期-获取报错日志列表
     * @Param: startDate
	* @Param  endDate
     * @return: com.yurun.model.vo.Result
     * @Author: JimmyYao
     * @Date: 2022/2/9
     */
    @GetMapping("exceptionloglist")
    public Result getExceptionLogListByDate(@RequestParam String startDate,
                                            @RequestParam String endDate){
        List<ExceptionLog> object=exceptionLogService.getExceptionLogListByDate(startDate, endDate);
        return Result.ok("通过日期获取出错日志列表成功",object);
    }
}
